<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

		<title><?php echo C('WEB_TITLE');?></title>

		<link rel="stylesheet" type="text/css" href="/Public/css/common.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/js/layui/css/layui.css" media="all"/>

		<link rel="stylesheet" href="/Public/js/datepicker/datepicker.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/crm/css/index.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/crm/css/style.css"/>

		<link rel="stylesheet" href="<?php echo C('PC_ICON_HTTP');?>">

		<script type="text/javascript" >

			const moduleName = "<?php echo (MODULE_NAME); ?>";

		</script>

        <link rel="stylesheet" href="/Public/js/viewer/css/viewer.min.css">
		
		<link rel="stylesheet" type="text/css" href="/Public/js/select2/select2.css" media="all"/>

		<script type="text/javascript" src="/Public/js/jquery-1.9.1.min.js"></script>
		
		<script type="text/javascript" src="/Public/js/jquery-ui.min.js"></script>

		<script type="text/javascript" src="/Public/js/cookie/jquery.cookie.js"></script>

		<script type="text/javascript" src="/Public/js/lang/<?php echo (getStrToLower(cookie('think_language'))); ?>.js"></script>

		<script type="text/javascript" src="/Public/js/colorpicker.js"></script>

		<script type="text/javascript" src="/Public/js/layer/layer.js"></script>

		<script type="text/javascript" src="/Public/js/layui/layui.js"></script>

        <script type="text/javascript" src="/Public/js/feeldesk.js"></script>

        <script type="text/javascript" src="/Public/crm/js/index.js"></script>

        <script type="text/javascript" src="/Public/js/jquery.nicescroll.js"></script>

		<script type="text/javascript" src="/Public/js/clipboard.min.js"></script>

		<script type="text/javascript" src="/Public/js/select2/select2.min.js"></script>

		<script type="text/javascript" src="/Public/js/select2/jquery.core.js"></script>

	</head>

<body>

<script type="text/javascript" src="/Public/js/datepicker/datepicker.all.js"></script>

<script type="text/javascript" src="/Public/js/datepicker/moment.min.js"></script>

<script type="text/javascript" src="/Public/js/datepicker/datepicker.en.js"></script>

<div class="welcome">

    <div class="numbers">

        <header>

            <form action="<?php echo U('welcome');?>" method="get" id="filterForm">

                <div class="item">

                    <input type="hidden" name='customer_auth' value="<?php echo ($customer_auth); ?>" />
					<div class="item-show">
                    <span><?php echo L('VIEW_RANGE');?>：</span>

                    <?php if(($customer_auth) == "all"): ?><span><?php echo L('WHOLE');?></span><?php endif; ?>

                    <?php if(($customer_auth) == "group"): ?><span><?php echo L('GROUP');?></span><?php endif; ?>

                    <?php if(($customer_auth) == "own"): ?><span><?php echo L('OWN');?></span><?php endif; ?>

                    <i class="layui-icon">&#xe625;</i>
					</div>

                    <div class="range-menu hidden"  id="auth">

                        <ul>

                            <?php if(($isAllViewAuth) > "0"): ?><li class="<?php if(($customer_auth) == "all"): ?>item-active<?php endif; ?>" data-value="all">

                                    <i class="iconfont icon-yuangong"></i> <?php echo L('WHOLE');?>

                                </li><?php endif; ?>

                            <?php if(($isGroupViewAuth) > "0"): ?><li class="<?php if(($customer_auth) == "group"): ?>item-active<?php endif; ?>" data-value="group">

                                    <i class="iconfont icon-weibiaoti101"></i> <?php echo L('GROUP');?>

                                </li><?php endif; ?>

                            <?php if(($isOwnViewAuth) > "0"): ?><li class="<?php if(($customer_auth) == "own"): ?>item-active<?php endif; ?>" data-value="own">

                                    <i class="iconfont icon-personal"></i> <?php echo L('OWN');?>

                                </li><?php endif; ?>

                        </ul>

                    </div>

                </div>

                <div class="item">
					<div class="item-show">
                    <input type="hidden" name='time_range' value="<?php echo ($time_range); ?>" />

					<input type="hidden" name='custom_time' value="" id="customTime" placeholder="yyyy-MM-dd - yyyy-MM-dd"/>

                    <span> <?php echo L('SELECT_TIME');?>：</span>

                    <?php if(($time_range) == "all"): ?><span><?php echo L('WHOLE');?></span><?php endif; ?>

                    <?php if(($time_range) == "today"): ?><span><?php echo L('TODAY');?></span><?php endif; ?>

                    <?php if(($time_range) == "week"): ?><span><?php echo L('WITHIN_A_WEEK');?></span><?php endif; ?>

                    <?php if(($time_range) == "month"): ?><span><?php echo L('WITHIN_ONE_MONTH');?></span><?php endif; ?>

					 <?php if(($time_range) == "custom"): ?><span><?php echo ($custom_time); ?></span><?php endif; ?>

                    <i class="layui-icon">&#xe625;</i>
					</div>

                    <div class="range-menu hidden"  id="range">

                        <ul>

                            <li class="<?php if(($time_range) == "all"): ?>item-active<?php endif; ?>" data-value="all"><?php echo L('WHOLE');?></li>

                            <li class="<?php if(($time_range) == "today"): ?>item-active<?php endif; ?>" data-value="today"><?php echo L('TODAY');?></li>

                            <li class="<?php if(($time_range) == "week"): ?>item-active<?php endif; ?>" data-value="week"><?php echo L('WITHIN_A_WEEK');?></li>

                            <li class="<?php if(($time_range) == "month"): ?>item-active<?php endif; ?>" data-value="month"><?php echo L('WITHIN_ONE_MONTH');?></li>

							<li class="<?php if(($time_range) == "custom"): ?>filter-active<?php endif; ?>" data-value="custom" id="customDate"><?php echo L('SELECT_DATE');?></li>

                        </ul>

                    </div>

                </div>

				<div class="clear"></div>

            </form>

        </header>

        <main>

            <ul>

                <a href="<?php echo U('Customer/index',['ImemberRole'=>$ImemberRole,'Itime'=>$Itime]);?>">

					<li>

						<div class="panel panel-customer">

							<i class="iconfont icon-customer1"></i>

							<p class="panel-name"><?php echo L('NUMBER_OF_CUSTOMERS');?></p>

							<p class="panel-number"><?php echo getCount($customer);?></p>

						</div>

					</li>

				</a>

				<a href="<?php echo U('Customer/contacter',['ImemberRole'=>$ImemberRole,'Itime'=>$Itime]);?>">

					<li>

						<div class="panel panel-contact">

							<i class="iconfont icon-101"></i>

							<p class="panel-name"><?php echo L('CONTACT');?></p>

							<p><?php echo getCount($contact);?></p>

						</div>

					</li>

				</a>

				<a href="<?php echo U('Customer/followup',['ImemberRole'=>$ImemberRole,'Itime'=>$Itime]);?>">

					<li>

						<div class="panel panel-recode">

							<i class="iconfont icon-jilu"></i>

							<p class="panel-name"><?php echo L('CONTACT_RECORD');?></p>

							<p><?php echo getCount($follow);?></p>

						</div>

					</li>

				</a>

				<a href="<?php echo U('Contract/index',['ImemberRole'=>$ImemberRole,'Itime'=>$Itime]);?>">

					<li>

						<div class="panel panel-order-number">

							<i class="iconfont icon-hetongguanli"></i>

							<p class="panel-name"><?php echo L('CONTRACT');?></p>

							<p><?php echo getCount($contract);?></p>

						</div>

					</li>

				</a>

				<a href="<?php echo U('Contract/index',['ImemberRole'=>$ImemberRole,'Itime'=>$Itime]);?>">

					<li>

						<div class="panel panel-order-price">

							<i class="iconfont icon-jine"></i>

							<p class="panel-name"><?php echo L('CONTRACT_AMOUNT');?></p>

							<p><?php echo ($contractTotalMoney); ?></p>

						</div>

					</li>

				</a>

            </ul>

        </main>

    </div>

    <div class="analysis">

        <div class="analysis1-left">

            <header>

                <i class="iconfont icon-rili"></i>

                <span><?php echo L('CUSTOMERS_FOLLOWED_TODAY');?></span>

            </header>

            <main>

                <div class="analysis-title">

                    <ul>

                        <li class="center"><?php echo L('CUSTOMER_NUMBER');?></li>

                        <li class="center"><?php echo L('CLIENT_NAME');?></li>

                        <li class="center"><?php echo L('TEL');?></li>

                        <li class="center"><?php echo L('CUSTOMER_RESPONSIBLE');?></li>

                    </ul>

                </div>

                <div class="analysis-item">

					<?php if(empty($customers["follow"])): ?><ul class="center">

                            <li class="no-data"><i class="iconfont icon-nothing fts20"></i><?php echo L('NO_DATA');?></li>

                        </ul>

                    <?php else: ?>

                    <?php if(is_array($customers["follow"])): $i = 0; $__LIST__ = $customers["follow"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><ul class="center" data-id="<?php echo (encrypt($vo["customer_id"],'CUSTOMER')); ?>">

                            <li class="center" mini='customer' ><?php echo ($vo["customer_prefix"]); echo ($vo["customer_no"]); ?></li>

                            <li class="center" mini='customer' title="<?php echo ($vo["detail"]["name"]); ?>"><?php echo ($vo["detail"]["name"]); ?></li>

                            <li class="center" mini='customer' ><?php echo ($vo["detail"]["phone"]); ?></li>

                            <li class="center" mini='customer' ><?php echo ($vo["member_name"]); ?></li>

                        </ul><?php endforeach; endif; else: echo "" ;endif; endif; ?>

                </div>

            </main>

        </div>

        <div class="analysis1-right">

            <header>

                <i class="iconfont icon-huishou"></i>

                <span><?php echo L('CUSTOMER_RECOVERED_3');?></span>

            </header>

            <main>

                <div class="analysis-title">

                    <ul>

                        <li class="center"><?php echo L('CUSTOMER_NUMBER');?></li>

                        <li class="center"><?php echo L('CLIENT_NAME');?></li>

                        <li class="center"><?php echo L('TEL');?></li>

                        <li class="center"><?php echo L('CUSTOMER_RESPONSIBLE');?></li>

                    </ul>

                </div>

                <div class="analysis-item">

					<?php if(empty($customers["recover"])): ?><ul class="center">

                            <li class="no-data"><i class="iconfont icon-nothing fts20"></i><?php echo L('NO_DATA');?></li>

                        </ul>

                    <?php else: ?>

                    <?php if(is_array($customers["recover"])): $i = 0; $__LIST__ = $customers["recover"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><ul data-id="<?php echo (encrypt($vo["customer_id"],'CUSTOMER')); ?>">

                            <li class="center" mini='customer' ><?php echo ($vo["customer_prefix"]); echo ($vo["customer_no"]); ?></li>

                            <li class="center" mini='customer' title="<?php echo ($vo["detail"]["name"]); ?>"><?php echo ($vo["detail"]["name"]); ?></li>

                            <li class="center" mini='customer' ><?php echo ($vo["detail"]["phone"]); ?></li>

                            <li class="center" mini='customer' ><?php echo ($vo["member_name"]); ?></li>

                        </ul><?php endforeach; endif; else: echo "" ;endif; endif; ?>

                </div>

            </main>

        </div>

    </div>

    <div class="analysis xingdong plr15">

        <div class="pb25">

            <header>

                <i class="iconfont icon-dongtai"></i>

                <span><?php echo L('ALL_DYNAMIC');?></span>

            </header>

            <main class="index-left-panel dynamic-panel">

				<fieldset class="layui-elem-field">

					<div class="layui-field-box">

						<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

							<div class="layui-tab-content">

								<!-- 我的动态 -->
								<div class="layui-tab-item layui-show">

									<ul class="layui-timeline myDynamic" id="myDynamic"></ul>

								</div>

							</div>

						</div>

					</div>

				</fieldset>

            </main>

        </div>


    </div>


    <script type="text/javascript">

        $(function ()
        {
            var item = $('.item');

			item.hover(function(){

				$(this).find('.range-menu').stop(true,true).slideDown('fast');

			},function(){

				$(this).find('.range-menu').stop(true,true).slideUp('fast');

			});

            $('#auth').find('li').on('click',function ()
            {
                var auth = $(this).data('value');

                $("input[name='customer_auth']").val(auth);

               $('#filterForm').submit();
            });

            $('#range').find('li').on('click',function ()
            {
                var range = $(this).data('value');

				if(range != 'custom')
				{
					$("input[name='time_range']").val(range);

					$('#filterForm').submit();
				}
            })

			layui.use('laydate',function()
			{
				var maxDate = "<?php echo (getDates(NOW_TIME,'2')); ?>";

				var laydate = layui.laydate;

				var option = {
					elem:'#customTime',
					eventElem: '#customDate',
					range: true,
					trigger: 'click',
					max: maxDate,
					btns: ['clear', 'confirm'],
					done: function(value)
					{
						$("input[name='time_range']").val('custom');

						$("input[name='custom_time']").val(value);

						$('#filterForm').submit();
					}
				};

				laydate.render(option);
			})
        })

    </script>

	<script type="text/javascript">

		var customer_auth = '<?php echo ($customer_auth); ?>';

		var Itime = '<?php echo ($Itime); ?>';

		layui.use('flow', function()
		{
			var flow = layui.flow;

			flow.load(
			{
				elem: '#myDynamic',
				isAuto:false,
				end:"<?php echo L('NO_MORE');?>",
				done: function(page, next)
				{
					var lis = [];

					var str = '';

					var l = 0;

					$.get("<?php echo U('Index/index');?>?request=flow&source="+customer_auth+"&Itime="+Itime+"&p="+page, function(res)
					{
						var dayText = '';

						var dayClass = 'date';

						if(res.data === '' || res.data == null || res.data.length == 0 )
						{
							next(lis.join(''), page < res.pages);
						}

						layui.each(res.data, function(key, val)
						{
							l = $("h3[data-create='"+key+"']");

							if(key === "<?php echo ($nowTime); ?>")
							{
								dayText = "<?php echo L('TODAY');?>";
							}
							else if(key === "<?php echo ($yesTime); ?>")
							{
								dayText = "<?php echo L('YESTERDAY');?>";
							}
							else
							{
								dayText = '&#xe63f;';

								dayClass = '';
							}

							str ="<li class='layui-timeline-item'>" +
								"<i class='layui-icon layui-timeline-axis "+dayClass+"'>"+dayText+"</i>" +
								"<div class='layui-timeline-content layui-text'>" +
								"<h3 class='layui-timeline-title' data-create="+key+">"+key+"</h3>";

							if(l.length > 0) str = '';

							var log_type_arr = ['follow','comment','analysis','competitor'];

							var operate_type_arr = ['10','13','16'];

							layui.each(val,function(k1,v1)
							{
								//str +="<span class='fts14 black6'><i class='iconfont icon-user'></i>"+v1.memberName+"</span>";

								str +="<p class=''><i class='quan ziquan'></i>"+v1.memberName+"</p>";

								str += "<p><i class='quan'></i>"+v1.eventTypeLang;
								//console.log($.inArray(v1.log_type,log_type_arr));
								if($.inArray(v1.operate_type,operate_type_arr) === -1 && $.inArray(v1.log_type,log_type_arr) === -1)
								{
									if(v1.operate_type == 15)
									{
										str += " <a href='javascript:' data-id="+v1.eventId+"> "+v1.log_name+"</a>";
									}
									else
									{
										if(v1.log_type === 'customer')
										{
											str += " <a href='javascript:' mini='customer' data-id="+v1.eventId+"> "+v1.log_name+"</a>";
										}
										else if(v1.log_type == 'contract')
										{
											str += " <a href='javascript:' mini='contract' data-id="+v1.eventId+"> "+v1.log_name+"</a>";
										}
                                        else if(v1.log_type == 'clue')
                                        {
                                            str += " <a href='javascript:' onclick=\"clickOpenDetailByA(this,'clue');\" data-id="+v1.eventId+"> "+v1.log_name+"</a>";
                                        }
                                        else if(v1.log_type == 'opportunity')
                                        {
                                            str += " <a href='javascript:' onclick=\"clickOpenDetailByA(this,'opportunity');\" data-id="+v1.eventId+"> "+v1.log_name+"</a>";
                                        }
										else
										{
											str += " <a href='javascript:' data-id="+v1.eventId+"> "+v1.log_name+"</a>";
										}
									}
								}

								str += "<span class='fr'>"+v1.create_at+"&nbsp;&nbsp;</span></p>"
							});

							if(l.length > 0)
							{
								l.parent('.layui-text').append(str);

								next('', page < res.pages);

								str = '';
							}

							lis.push(str);
						});

						if(l.length === 0)
						{
							next(lis.join(''), page < res.pages);
						}
					});
				}
			});
		});

	</script>

</div>